//1. 引入路由懒加载
import {lazy} from "react"

//2. 定义一个数组

export let mainRouter = [
    {
        path:"/index/home",
        element:lazy(()=>import("../page/Index/Home")),
        title:"首页"
    },
    {
        path:"/index/classify",
        element:lazy(()=>import("../page/Index/Classify")),
        title:"分类"
    },
    {
        path:"/index/shopcar",
        element:lazy(()=>import("../page/Index/ShopCar")),
        title:"购物车"
    },
    {
        path:"/index/my",
        element:lazy(()=>import("../page/Index/My")),
        title:"我的"
    }
]

const routes = [
    {
        from:"/",
        to:"/index/home"
    },
    {
        path:"/index",
        element:lazy(()=>import("../page/Index")),
        children:mainRouter
    },
    {
        path:"/detail/:id",
        element:lazy(()=>import("../page/Detail"))
    },
    {
        path:"/login",
        element:lazy(()=>import("../page/Login"))
    },
    {
        path:"*",
        element:lazy(()=>import("../page/Eorry404"))
    }
]

// 3. 把定义好的路由抛出
export default routes
// module.exports={

// }
